package com.example.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StringRedisController {
	
	@Autowired
	private ValueOperations<String, Object> valueOperations;
	
	@RequestMapping("setStr")
	public String setStr(){
		valueOperations.set("cs", "hello redis");
		String cs = (String) valueOperations.get("cs");
		System.out.println(cs);
		String cs1 = (String) valueOperations.getAndSet("cs", "cs hello redis");
		System.out.println(cs1);
		String cs2 = (String) valueOperations.get("cs");
		System.out.println(cs2);
		return "cs";
	}
}
